<?php
/**
 * @subpackage Components
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1
 * @license    GNU/GPL
*/
 
// no direct access
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.application.component.view');
 
/**
 * HTML View class for the HelloWorld Component
 *
 * @package    HelloWorld
 */
 
class HizkuntzakViewCreate extends JView
{
    function display($tpl = null)
    {
        $greeting = "Hello Create!";
        $this->assignRef( 'greeting', $greeting );
 
        parent::display($tpl);
    }
    
	function createSongLang(){
    	
    	$this->addCSS();
		$this->addJavascripts();
		
    	$model = &$this->getModel();
        
        $rsc = $model->selectLangRsc();
		$this->assignRef('rsc',$rsc);
		
		$songLang = $model->getSong();
		$this->assignRef('song', $songLang);
		
		$lang = $model->getLang();
		$this->assignRef('lang', $lang);
		
		$c_lang = $model->checkLang();
		$this->assignRef('c_lang', $c_lang);
		
    	parent::display($tpl);
    }
    
	function createNumbersLang(){
    	
    	$this->addCSS();
		$this->addJavascripts();
		
    	$model = &$this->getModel();
        
        $rsc = $model->selectLangRsc();
		$this->assignRef('rsc',$rsc);
		
		$numberLang = $model->getLangNumbers();
		$this->assignRef('numbersLang', $numberLang);
		
		$lang = $model->getLang();
		$this->assignRef('lang', $lang);
		
		$c_lang = $model->checkLang();
		$this->assignRef('c_lang', $c_lang);
		
    	parent::display($tpl);
    }
    
    function createWordsLang(){
    	
    	$this->addCSS();
		$this->addJavascripts();
		
    	$model = &$this->getModel();
        
        $rsc = $model->selectLangRsc();
		$this->assignRef('rsc',$rsc);
		
		$wordsLang = $model->getLangWords();
		$this->assignRef('wordsLang',$wordsLang);
		
		$lang = $model->getLang();
		$this->assignRef('lang', $lang);
		
		$c_lang = $model->checkLang();
		$this->assignRef('c_lang', $c_lang);
		
    	parent::display($tpl);
    }
    
    function createQasLang(){
    	
    	$this->addCSS();
		$this->addJavascripts();
		
    	$model = &$this->getModel();
        
        $rsc = $model->selectLangRsc();
		$this->assignRef('rsc',$rsc);
		
		$qasLang = $model->getLangQasEdit();
		$this->assignRef('qasLang',$qasLang);

		$lang = $model->getLang();
		$this->assignRef('lang', $lang);
		
		$c_lang = $model->checkLang();
		$this->assignRef('c_lang', $c_lang);
		
    	parent::display($tpl);
    }
    
    function createLang($tpl = null){
    	
    	$this->addCSS();
		$this->addJavascripts();
		
    	$model = &$this->getModel();
        
        $rsc = $model->selectLangRsc();
		$this->assignRef('rsc',$rsc);
 
		$lang = $model->getLang();
		$this->assignRef('lang', $lang);
		
        parent::display($tpl);
    }
    
	function createWord($tpl = null){
    	
		$this->addCSS();
		$this->addJavascripts();
		
    	$model = &$this->getModel();
        
        $rsc = $model->selectLangRsc();
		$this->assignRef('rsc',$rsc);
		
		$word = $model->getWord();
		$this->assignRef('word', $word);
		
        parent::display($tpl);
    }
    
	function createQA($tpl = null){
    	
		$this->addCSS();
		$this->addJavascripts();
		
    	$model = &$this->getModel();
        
        $rsc = $model->selectLangRsc();
		$this->assignRef('rsc',$rsc);
		
		$qa = $model->getQa();
		$this->assignRef('qa', $qa);
		
        parent::display($tpl);
    }
    
    function createInfo($tpl = null){
    	
    	$this->addCSS();
		$this->addJavascripts();
		
    	$model = &$this->getModel();
        
        $rsc = $model->selectLangRsc();
		$this->assignRef('rsc',$rsc);
 
        parent::display($tpl);
    }
    
	private function addCSS(){
		$option=JRequest::getCmd('option');
			
		$document=&JFactory::getDocument();
			
		$document->addStyleSheet('components/'.$option.'/css/smoothness/jquery-ui-1.8.15.custom.css');
		$document->addStyleSheet('components/'.$option.'/css/validationEngine.jquery.css');
	}
	
	private function addJavascripts(){
		$option=JRequest::getCmd('option');
			
		$document=&JFactory::getDocument();
		$document->addScript('components/'.$option.'/js/jquery-1.6.2.min.js');
		$document->addScript('components/'.$option.'/js/jquery-ui-1.8.15.custom.min.js');
		$document->addScript('components/'.$option.'/js/jquery.validationEngine.js');
		$document->addScript('components/'.$option.'/js/hizkuntzak-forms.js');
		
		//Set util Language: ES or EU
			$model = &$this->getModel();
			
			if($model->checkLang() == 'eu-ES'){
				$document->addScript('components/'.$option.'/js/languages/jquery.validationEngine-eu.js');	
			}
			else{
				$document->addScript('components/'.$option.'/js/languages/jquery.validationEngine-es.js');
			}
	}
}

